<?php
$todayBegin = strtotime(date('Y-m-d',time()).' 00:00:00');
$todayEnd = $todayBegin + 60 * 60 * 24;
if (!isset($availableList) || $availableList == NULL) {
    $availableList = array();
    if (isset($findText) && $findText != NULL) {
        if (isset($findContext) && $findContext != NULL) {
            $findContext = unserialize($findContext);
        } else {
            $findContext = Blyn::app()->getUIManager()->getCurrentScreen()->getContextVariable('findContext');
        }

        if ($findContext == NULL) {
            $availableList = Blyn::app()->getActiveApp()->findByFindText($findText);
            $totalRows = Blyn::app()->getActiveApp()->findCountByFindText($findText);
        } else {
            $availableList = Blyn::app()->getActiveApp()->findByFindText($findText, $findContext);
            $totalRows = Blyn::app()->getActiveApp()->findCountByFindText($findText);
        }
    }
}
 else {
    $totalRows = Blyn::app()->getActiveApp()->findCountByFindText($findText);
}
?>
<meta name="viewport" contdent="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="full-screen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<style type="text/css">
.nav-dropdown ul {margin: 0;}
    .nav-dropdown ul li {
    height: 30px;
    line-height: 30px;
}
.btn-d{
    height: 30px;
    padding: 3px 12px;
    background-color: white;
    border: 1px solid #2bb2a3;
    color: #2bb2a3;
}
.seeDetail{
display: inline-block;
color: #2bb2a3;
border: 1px solid #2bb2a3;
padding: 8px;
border-radius: 4px;
font-size: 14px;
}
.left_picture_2{
float: left;
width: 90px;
height: 95px;
margin-right: 5px;
margin-left: 5px;
}
</style>
<body>
    <script type="text/javascript">
$(".nav-dropdown-btn").click(function() {
    $("#nav-dropdown").toggle();
});
</script>
    <header class="navbar" style="min-height:52px;margin-bottom:0px;">
        <table style="width:100%;">
            <tr>
                <td style="width:10%;text-align:left;">
                    <div style="margin-top:8px;margin-left:10px;">
                        <?php
                        echo $control->getAjaxLink(array('name' => '<img src="'.Yii::app()->request->baseUrl.'/images/mobile/backbtn.png'.'" />', 'id' => 'manageBooking'), array(
                            'htmlOptions' => array(
                            'enctype' => 'multipart/form-data'
                        )));
                        ?> 
                    </div>
                  <div class="nav-wrap-right">
                        <a class="react nav-dropdown-btn" style="width:30px;margin-right:8px;">
                            <span class="nav-btn">
                                <i class="text-icon"><img src="<?php echo Yii::app()->request->baseUrl.'/images/mobile/wave.png';?>" /></i>导航
                            </span>
                        </a>
                    </div>  
                    <div id="nav-dropdown" class="nav-dropdown" style="top:52px;width:100px;">
                        <ul>
                            <li><?php
                                echo $control->getAjaxLink(array('name' => '首页', 'id' => 'manageBooking'), array(
                                    'htmlOptions'=>array(
                                    'class'=>'react',
                                    'enctype'=>'multipart/form-data'
                                )));?> 
                            </li>
                            <li><?php
                                echo $control->getAjaxLink(array('name' => '选择日期', 'id' => 'manageBooking_selectTime'), array(
                                    'backPage'=>'manageBooking_remainList',
                                    'findText'=>$findText,
                                    'flagText'=>$flagText,
                                    'htmlOptions'=>array(
                                    'class'=>'react',
                                    'enctype'=>'multipart/form-data'
                                )));?></li>
                        </ul>
                   </div>
                </td>
                <td style="width:80%;text-align:center;"><h4 style="margin-top:15px;"><?php echo $flagText;?></h4></td>
                <td style="width:10%;text-align:right;"></td>
            </tr>
        </table>
        <div id="ajax-loaderdiv" style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;">
            <img src="/billyn-dev/images/ajax-loader.gif" class="ajax-loader"style="position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;"/>
        </div>
    </header>
        <dl class="list"><?php
            if(count($availableList)) {
                foreach ($availableList as $id => $bookingItem) {
                    $date = date('Y.n.j', $bookingItem->getItem('startTime')->value);
                    $startTime = date('G:i', $bookingItem->getItem('startTime')->value);
                    $endTime = date('G:i', $bookingItem->getItem('endTime')->value);
                    $price =  $bookingItem->getItem('price')->value;
                    $region = $bookingItem->getItem('region')->value;
                    $str = $bookingItem->getItem('courtName')->value;
                    $str = trim($str);
                    if (!empty($str)) {
                        $result = '';
                        for ($i = 0; $i < strlen($str); $i++) {
                            if (is_numeric($str[$i])) {
                                $result.=$str[$i];
                            }
                        }
                    }
                    $bookdetail = new BWMessage($result);
                    $courtMedia = $bookdetail->getMediaManager()->getMedia('image');
                    $courtAddress = $bookdetail->getMediaManager()->getMedia('address')->getContent();
                    $courtImage = NULL;
                    if ($courtMedia instanceof BWMedia) {
                        $courtImage = $bookdetail->getMediaManager()->getMedia('image')->getContent();
                    }
                    ?>

                    <dd style="position: relative;">
                        <div class="react" style="padding-top: 10px;padding-bottom: 6px;">
                            <div class="left_picture left_picture_2" >
                                <img src="<?php echo Yii::app()->request->baseUrl.$courtImage;?>" width="100%" height="100%"/>
                            </div>
                            <span style="color:black;display: inline-block;margin-bottom: 6px;"><?php echo $bookingItem->getItem('courtDisplayName')->value; ?> </span>
                            <br/>
                                <span class="time" style="display: inline-block;margin-bottom: 6px;color: #FDB338;">
                                    <i class="text-icon" style="font-family: inherit;"><span class="booking_date"><?php echo date("Y/m/d").' '.$startTime; ?>-<?php echo $endTime; ?></i>
                                </span>
                            <br/>
                            <span style="display: inline-block;margin-bottom: 6px;color: gray;"><?php echo '场地价格：'.$price;?></span>
                            <br/>
                            <span class="" style="display: inline-block;margin-bottom: 6px;">
                                <strong style="color:#2BB2A3;">地点：<?php echo $courtAddress;?></strong>
                            </span>
                        </div>
                        <div class="right_btn" style="position:absolute;right:10px;bottom:10px;">
                            <span class="line-right">
                                <?php
                                echo $control->getAjaxLink(array('name' => '查看详情', 'id' => 'manageBooking_remainDetail'), array(
                                    'finText'=>$findText,
                                    'flagText'=>$flagText,
                                    'bookingId'=>$bookingItem->getId(),
                                    'htmlOptions'=>array(
                                    'enctype'=>'multipart/form-data',
                                        'class'=>'seeDetail',
                                        'style'=>'text-decoration: none',
                                )));
                                ?> 
                            </span>
                        </div>
                    </dd><?php 
                } 
            } else {?>
                <div style="height:200px;background-color:#FCFCFC;color:chocolate;text-align:center;padding-top:100px;">
                    没有剩余场地！
                </div><?php
            }?>
        </dl>
    <footer>
        <div class="footer-copyright">
            <div class="hr"></div>
            <span class="footer-copyright-text">
                Copyright © 2014 billyn.net </span>
        </div>
    </footer>
</body>